import { useDetail, useList } from "@/hooks";
import { getUserInfoUrl, getUserTypeValue } from "@/command/apiTool";
import { getAction } from "@/command/netTool";
import { ref } from "vue";
import * as vant from "vant";
const { showFailToast, showSuccessToast } = vant;
export const useRequest = () => {
  const page = ref();
  // 最新快讯
  const [newInfoList] = useDetail(
    getUserInfoUrl({
      dh: "/api/H5/gov/richTraceSourceApply/large/queryTraceabilityFlash",
      xh: "/api/H5/gov/richTraceSourceApply/small/queryTraceabilityFlash",
    }),
    []
  );
  // 溯源情况
  const [queryApplyNum] = useDetail(
    getUserInfoUrl({
      dh: "/api/H5/gov/richTraceSourceApply/large/queryApplyNum",
      xh: "",
    }),
    {
      acceptNum: "",
      acceptNumYear: [],
      smallApplyNum: "",
      smallApplyNumYear: [],
    }
  );
  // 按钮操作
  const btnAction = (params: any) => {
    getAction(
      "/api/H5/gov/richTraceSourceApply/large/accept",
      { ...params },
      { isResolve: true }
    ).then((e) => {
      console.log("eee", e);
      // showSuccessToast(e);
      // 刷新接口
      page.value.reset();
    });
  };
  return {
    newInfoList,
    btnAction,
    queryApplyNum,
    page,
  };
};
